<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
	<script language="JavaScript" type="text/JavaScript">
		window.onload = function()
		{
			if('${showflights}' == "true")
				document.getElementById("div1").style.display = 'block';
			else
				document.getElementById("div1").style.display = 'none';
			if('${userSession}' ==  "" || '${userSession}' ==  null)
				self.location = "login.jsp";
		}
		
		function setParent(alid, aircraft, date)
		{
			window.opener.setFlight(alid, aircraft, date);
	        window.close();
		}
		
	</script>
	
	<script language="JavaScript" type="text/JavaScript" src="datetimepicker.js">
	</script>
	
	<body>
		<form method="post" action="flightList">
			<h1>Flight List</h1>
			<table cellspacing="10">
	
				<tr><td>Date: </td>
				<td>
				<input id="demo1" name="date" type="text" size="10" value="${date}"><a href="javascript:NewCal('demo1','ddmmyyyy')">&nbsp;<img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
				</td>
				<td>Source: </td>
				<td><input type="text" name="source" size="20" maxlength="20" value="${source}"/></td>
				<td>Destination: </td>
				<td><input type="text" name="destination" size="20" maxlength="20" value="${destination}"/></td></tr>
			</table><br><br>

			<input id="submit" type="submit" name="submit" value="Get Flights"/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="hidden" name="flightlist" value="FL"/>
			<br><br>
			<div id="div1">
			<table cellspacing=10>
				<tr>
				<td>Aircraft</td>
				<td>Depature Date</td>
				<td>Arrival Date</td>
				<td>Departure Time</td>
				<td>Arrival Time</td>
				<td>Source</td>
				<td>Destination</td>
				<td>Status</td>
				</tr>
			</table>

			<table cellspacing=10>
				<c:forEach var="f" items="${flights}">
				<tr>
				<td><a style="color:blue;" href="javascript:setParent('${f.alid}', '${f.aircraft}', '${f.deptdate}');">${f.aircraft}</a></td>
				<td>${f.deptdate}</td>
				<td>${f.arrvdate}</td>
				<td>${f.depttime}</td>
				<td>${f.arrvtime}</td>
				<td>${f.source}</td>
				<td>${f.destination}</td>
				<td>${f.status}</td>
				</tr>
				</c:forEach>
			</table>
			</div>
			
		</form>
	</body>
</html>
